// PART 4 PRODUCES RESULTS FOR TABLE 10

clear
cd "\\file\UsersW$\wrr15\Home\My Documents\My Files\XINDONG XUE\META-ANALYSIS\REVISION FOR JHE\DATA AND CODE"
set more off
set type double
graph drop _all
program drop _all
set scheme s2mono
log using "Part4 Results(20191130).smcl", replace
use "sc_data(20191130).dta"

******************************************************************************
*DEFINITION OF BASIC VARIABLES
******************************************************************************
gen tstat = real(tstatistics)
gen negative = 1
replace negative = -1 if ((badhealth == 1 & badsc == 0) | (badhealth == 0 & badsc == 1))
replace tstat = tstat*negative
gen df = nobs
gen obsno = _n
replace df = . if tstat == .
gen r = tstat/sqrt(tstat^2+df)
gen varR = (1-r^2)/df
gen seR = sqrt(varR)
gen pcc = r

quietly summ pcc, detail
keep if pcc > r(p1) & pcc < r(p99) 

// Calculating study weights
bysort id: egen numberests = count(id)
tabulate numberests 
gen weight = 1/numberests

// Study Type
describe journal
gen journal2 = journal
encode journal, gen(njournal)
drop journal
gen journal=(njournal != .)

// Countries
gen eastasia=(country_region=="East_Asia")
gen usa=(country_region=="USA")
gen westnortheurope=(country_region=="West_North_Europe")
gen highincome=(country_region=="High-income countries")
gen othercountry = 1 - eastasia - usa - westnortheurope - highincome

// Social Capital Measures
gen cognitive = (cognitivestructual == 0)
replace cognitive = . if cognitivestructual == .
gen structural = (cognitivestructual == 1)
replace structural = . if cognitivestructual == .
gen bonding = (bondingbridginglinking == 0)
replace bonding = . if bondingbridginglinking == .
gen bridging = (bondingbridginglinking == 1)
replace bridging = . if bondingbridginglinking == .
gen linking = (bondingbridginglinking == 2)
replace linking = . if bondingbridginglinking == .
sum bondingbridginglinking bonding bridging linking

quietly summ numberofscvariables
// We replace numberofscvariables with deviation from mean
replace numberofscvariables = numberofscvariables - r(mean)

// Estimation Method
gen otherestimation = 1 - ols - fgls - probitlogit - orderedprobitlogit - orhr - hlm - iv 
quietly summ numberofscvariables
// We replace numberofscvariables with deviation from mean
replace numberofscvariables = numberofscvariables - r(mean)

// Calculation of t-statistic
gen tcalculatedbyci=(tcalculatedbycise==1 & cilowerbound != .)
gen tcalculatedbypvalue2 = tcalculatedbypvalue
replace tcalculatedbypvalue = (tcalculatedbypvalue2 == 1)
gen tnormal = 1 - tcalculatedbyci - tcalculatedbypvalue

// Generating transformed variables for FE and RE
gen fetstatR = r/seR
metareg r seR pubyear panel iv eastasia westnortheurope highincome othercountry ///
physicalhealth mentalhealth selfreported cognitivestructual bondingbridginglinking ///
numberofscvariables age gender education maritalstatus income ols orhr hlm ///
seother tnormal tcalculatedbypvalue, wsse(seR)
scalar tau2 =  e(tau2)
gen revarR = varR + tau2
gen reseR = sqrt(revarR)
gen retstatR = r/reseR
gen repubbiasR = seR/reseR

************************************
************************************
************************************
************ TABLE 10 **************
************************************
************************************
************************************

**********************************************
************ FIXED EFFECTS *******************
**********************************************
gen conss = 1/seR
gen cognitivee = cognitive/seR
gen bondingg= bonding/seR
gen bridgingg = bridging/seR
gen pubyearr = pubyear/seR
gen individualscc = individualsc/seR
gen panell = panel/seR
gen ivv = iv/seR
gen eastasiaa = eastasia/seR
gen westnortheuropee = westnortheurope/seR
gen highincomee = highincome/seR
gen othercountryy = othercountry/seR
gen physicalhealthh = physicalhealth/seR
gen mentalhealthh = mentalhealth/seR
gen selfreportedd = selfreported/seR
gen numberofscvariabless = numberofscvariables/seR
gen agee = age/seR
gen genderr = gender/seR
gen educationn = education/seR
gen maritalstatuss = maritalstatus/seR
gen incomee = income/seR
gen olss = ols/seR
gen orhrr = orhr/seR
gen hlmm = hlm/seR
gen seotherr = seother/seR
gen tnormall = tnormal/seR
gen tcalculatedbypvaluee = tcalculatedbypvalue/seR
gen cogphysicall = cognitive*physicalhealth/seR
gen cogmentall = cognitive*mentalhealth/seR
gen bondphysicall = bonding*physicalhealth/seR
gen bondmentall = bonding*mentalhealth/seR

// NOTE: The constant term is the SER term

*--------------------------------------------------------*
*   TABLE: FixedEffects(Weight1) // Stepwise Regression  *
*--------------------------------------------------------*

////////////////////////////////////////////
//////////////  FULL SAMPLE  ///////////////
////////////////////////////////////////////
quietly regress fetstatR conss bondingg bridgingg pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee 
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee , ///
backward bic fix(conss bondingg bridgingg)

// Fixed Effects - Equal weight to each estimate (Column 1)
regress fetstatR conss bondingg bridgingg pubyearr individualscc othercountryy physicalhealthh mentalhealthh ///
numberofscvariabless agee genderr educationn incomee olss ///
seotherr tcalculatedbypvaluee if esample == 1, vce(cluster id) 
test (bondingg bridgingg)

////////////////////////////////////////////////
//////////////  PHYSICAL HEALTH  ///////////////
////////////////////////////////////////////////
drop esample 
quietly regress fetstatR conss bondingg pubyearr individualscc panell ivv eastasiaa ///
westnortheuropee highincomee othercountryy selfreportedd numberofscvariabless ///
agee genderr educationn maritalstatuss incomee olss orhrr hlmm seotherr ///
tnormall tcalculatedbypvaluee if physicalhealth == 1
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee ///
othercountryy selfreportedd numberofscvariabless agee genderr educationn ///
maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee ///
if esample == 1, backward bic fix(conss bondingg )

// Fixed Effects - Equal weight to each estimate (Column 1)
regress fetstatR conss bondingg pubyearr westnortheuropee  othercountryy  ///
selfreportedd genderr educationn incomee hlmm seotherr tcalculatedbypvaluee if esample == 1, ///
vce(cluster id) 

//////////////////////////////////////////////
//////////////  MENTAL HEALTH  ///////////////
//////////////////////////////////////////////
drop esample 
quietly regress fetstatR conss bondingg pubyearr individualscc panell ivv eastasiaa ///
westnortheuropee highincomee othercountryy selfreportedd numberofscvariabless ///
agee genderr educationn maritalstatuss incomee olss orhrr hlmm seotherr ///
tnormall tcalculatedbypvaluee if mentalhealth == 1
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee ///
othercountryy selfreportedd numberofscvariabless agee genderr educationn ///
maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee ///
if esample == 1, backward bic fix(conss bondingg )

// Fixed Effects - Equal weight to each estimate (Column 1)
regress fetstatR conss bondingg pubyearr individualscc panell numberofscvariables agee ///
genderr educationn maritalstatuss incomee orhrr hlmm tcalculatedbypvaluee if esample == 1, ///
vce(cluster id) 

//////////////////////////////////////////////
//////////////  GENERAL HEALTH  //////////////
//////////////////////////////////////////////
drop esample 
quietly regress fetstatR conss bondingg pubyearr individualscc panell ivv eastasiaa ///
westnortheuropee highincomee othercountryy selfreportedd numberofscvariabless ///
agee genderr educationn maritalstatuss incomee olss orhrr hlmm seotherr ///
tnormall tcalculatedbypvaluee if generalhealth == 1
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee ///
othercountryy selfreportedd numberofscvariabless agee genderr educationn ///
maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee ///
if esample == 1, backward bic fix(conss bondingg )

// Fixed Effects - Equal weight to each estimate (Column 1)
regress fetstatR conss bondingg pubyearr eastasiaa othercountryy ///
selfreportedd numberofscvariables agee incomee olss hlmm seotherr ///
tnormall tcalculatedbypvaluee if esample == 1, vce(cluster id) 

/////////////////////////////////////////////////////////////////
//////////////  FULL SAMPLE w/ INTERACTION TERMS  ///////////////
/////////////////////////////////////////////////////////////////
drop esample
quietly regress fetstatR conss bondingg bondphysicall bondmentall pubyearr ///
individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1, ///
backward bic fix(conss bondingg bondphysicall bondmentall)

// Fixed Effects - Equal weight to each estimate (Column 1)
regress fetstatR conss bondingg bondphysicall bondmentall pubyearr ///
individualscc othercountryy physicalhealthh mentalhealthh ///
numberofscvariabless agee genderr educationn incomee olss ///
seotherr tcalculatedbypvaluee if esample == 1, vce(cluster id)

*--------------------------------------------------------*
*   TABLE: FixedEffects(Weight2) // Stepwise Regression  *
*--------------------------------------------------------*

////////////////////////////////////////////
//////////////  FULL SAMPLE  ///////////////
////////////////////////////////////////////
drop esample 
quietly regress fetstatR conss bondingg bridgingg pubyearr individualscc panell ivv eastasiaa ///
westnortheuropee highincomee othercountryy physicalhealthh mentalhealthh ///
selfreportedd numberofscvariabless agee genderr educationn maritalstatuss ///
incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight]
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if esample == 1, ///
backward bic fix(conss bondingg bridgingg)

// Fixed Effects - Equal weight to each study (Column 2)
regress fetstatR conss bondingg bridgingg pubyearr individualscc othercountryy ///
physicalhealthh mentalhealthh numberofscvariabless agee genderr incomee olss ///
hlmm seotherr tcalculatedbypvaluee [pweight = weight] ///
if esample == 1, vce(cluster id) 
test (bondingg bridgingg)

////////////////////////////////////////////////
//////////////  PHYSICAL HEALTH  ///////////////
////////////////////////////////////////////////
drop esample 
quietly regress fetstatR conss bondingg pubyearr individualscc panell ivv eastasiaa ///
westnortheuropee highincomee othercountryy selfreportedd numberofscvariabless ///
agee genderr educationn maritalstatuss incomee olss orhrr hlmm seotherr ///
tnormall tcalculatedbypvaluee [pweight = weight] if physicalhealth == 1
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee ///
othercountryy selfreportedd numberofscvariabless agee genderr educationn ///
maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee ///
[pweight = weight] if esample == 1, backward bic fix(conss bondingg )

// Fixed Effects - Equal weight to each study (Column 2)
regress fetstatR conss bondingg pubyearr individualscc eastasiaa westnortheuropee  othercountryy  ///
numberofscvariabless genderr educationn incomee hlmm seotherr tnormall tcalculatedbypvaluee ///
[pweight = weight] if esample == 1, vce(cluster id) 

//////////////////////////////////////////////
//////////////  MENTAL HEALTH  ///////////////
//////////////////////////////////////////////
drop esample 
quietly regress fetstatR conss bondingg pubyearr individualscc panell ivv eastasiaa ///
westnortheuropee highincomee othercountryy selfreportedd numberofscvariabless ///
agee genderr educationn maritalstatuss incomee olss orhrr hlmm seotherr ///
tnormall tcalculatedbypvaluee [pweight = weight] if mentalhealth == 1
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee ///
othercountryy selfreportedd numberofscvariabless agee genderr educationn ///
maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee ///
[pweight = weight] if esample == 1, backward bic fix(conss bondingg )

// Fixed Effects - Equal weight to each study (Column 2)
regress fetstatR conss bondingg pubyearr individualscc panell westnortheuropee othercountryy selfreportedd  ///
numberofscvariables maritalstatuss orhrr hlmm tnormall tcalculatedbypvaluee ///
[pweight = weight] if esample == 1, vce(cluster id) 

//////////////////////////////////////////////
//////////////  GENERAL HEALTH  //////////////
//////////////////////////////////////////////
drop esample 
quietly regress fetstatR conss bondingg pubyearr individualscc panell ivv eastasiaa ///
westnortheuropee highincomee othercountryy selfreportedd numberofscvariabless ///
agee genderr educationn maritalstatuss incomee olss orhrr hlmm seotherr ///
tnormall tcalculatedbypvaluee [pweight = weight] if generalhealth == 1
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee ///
othercountryy selfreportedd numberofscvariabless agee genderr educationn ///
maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee ///
[pweight = weight] if esample == 1, backward bic fix(conss bondingg )

// Fixed Effects - Equal weight to each study (Column 2)
regress fetstatR conss bondingg pubyearr ivv highincomee othercountryy ///
numberofscvariables incomee olss hlmm seotherr ///
tnormall [pweight = weight] if esample == 1, vce(cluster id) 

/////////////////////////////////////////////////////////////////
//////////////  FULL SAMPLE w/ INTERACTION TERMS  ///////////////
/////////////////////////////////////////////////////////////////
drop esample
quietly regress fetstatR conss bondingg bondphysicall bondmentall pubyearr ///
individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight]
gen esample = e(sample)

vselect fetstatR pubyearr individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if esample == 1, ///
backward bic fix(conss bondingg bondphysicall bondmentall physicalhealthh mentalhealthh)

// Fixed Effects - Equal weight to each study (Column 2)
regress fetstatR conss bondingg bondphysicall bondmentall physicalhealthh ///
mentalhealthh pubyearr individualscc othercountryy  ///
numberofscvariabless agee genderr incomee olss hlmm seotherr ///
tcalculatedbypvaluee [pweight = weight] if esample == 1, vce(cluster id)


**********************************************
************ RANDOM EFFECTS ******************
**********************************************
replace conss = 1/reseR
replace cognitivee = cognitive/reseR
replace bondingg= bonding/reseR
replace bridgingg = bridging/reseR
replace pubyearr = pubyear/reseR
replace individualscc = individualsc/reseR
replace panell = panel/reseR
replace ivv = iv/reseR
replace eastasiaa = eastasia/reseR
replace westnortheuropee = westnortheurope/reseR
replace highincomee = highincome/reseR
replace othercountryy = othercountry/reseR
replace physicalhealthh = physicalhealth/reseR
replace mentalhealthh = mentalhealth/reseR
replace selfreportedd = selfreported/reseR
replace numberofscvariabless = numberofscvariables/reseR
replace agee = age/reseR
replace genderr = gender/reseR
replace educationn = education/reseR
replace maritalstatuss = maritalstatus/reseR
replace incomee = income/reseR
replace olss = ols/reseR
replace orhrr = orhr/reseR
replace hlmm = hlm/reseR
replace seotherr = seother/reseR
replace tnormall = tnormal/reseR
replace tcalculatedbypvaluee = tcalculatedbypvalue/reseR
replace cogphysicall = cognitive*physicalhealth/reseR
replace cogmentall = cognitive*mentalhealth/reseR
replace bondphysicall = bonding*physicalhealth/reseR
replace bondmentall = bonding*mentalhealth/reseR

*---------------------------------------------------------*
*   TABLE: RandomEffects(Weight1) // Stepwise Regression  *
*---------------------------------------------------------*

////////////////////////////////////////////
//////////////  FULL SAMPLE  ///////////////
////////////////////////////////////////////
drop esample 
quietly regress retstatR conss repubbiasR bondingg bridgingg pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee 
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee if esample == 1, backward bic fix(conss bondingg bridgingg)

// Random Effects - Equal weight to each estimate (Column 3)
regress retstatR conss bondingg bridgingg pubyearr individualscc eastasiaa  ///
othercountryy physicalhealthh mentalhealthh numberofscvariabless agee incomee olss ///
orhrr tcalculatedbypvaluee if esample == 1, noc vce(cluster id)
test (bondingg bridgingg)

////////////////////////////////////////////////
//////////////  PHYSICAL HEALTH  ///////////////
////////////////////////////////////////////////
drop esample 
quietly regress retstatR conss repubbiasR bondingg pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee if physicalhealth == 1
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1, ///
backward bic fix(conss bondingg)

// Random Effects - Equal weight to each estimate (Column 3)
regress retstatR conss bondingg highincomee ///
othercountryy genderr maritalstatuss olss orhrr hlmm seotherr ///
tcalculatedbypvaluee if esample == 1, noc vce(cluster id)

//////////////////////////////////////////////
//////////////  MENTAL HEALTH  ///////////////
//////////////////////////////////////////////
drop esample 
quietly regress retstatR conss repubbiasR bondingg pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee if mentalhealth == 1
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1, ///
backward bic fix(conss bondingg)

// Random Effects - Equal weight to each estimate (Column 3)
regress retstatR conss bondingg individualscc eastasiaa highincomee ///
othercountryy numberofscvariabless genderr maritalstatuss orhrr tnormall tcalculatedbypvaluee if esample == 1, noc vce(cluster id)

//////////////////////////////////////////////
//////////////  GENERAL HEALTH  //////////////
//////////////////////////////////////////////
drop esample 
quietly regress retstatR conss repubbiasR bondingg pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee if generalhealth == 1
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1, ///
backward bic fix(conss bondingg)

// Random Effects - Equal weight to each estimate (Column 3)
regress retstatR conss bondingg pubyearr eastasiaa ///
othercountryy selfreportedd numberofscvariabless agee incomee olss hlmm seotherr tcalculatedbypvaluee if esample == 1, noc vce(cluster id)

/////////////////////////////////////////////////////////////////
//////////////  FULL SAMPLE w/ INTERACTION TERMS  ///////////////
/////////////////////////////////////////////////////////////////
drop esample
quietly regress retstatR conss repubbiasR bondingg bondphysicall bondmentall pubyearr ///
individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy physicalhealthh mentalhealthh selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee ///
olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee if esample == 1, ///
backward bic fix(conss bondingg bondphysicall bondmentall)

// Random Effects - Equal weight to each estimate (Column 3)
regress retstatR conss bondingg bondphysicall bondmentall pubyearr ///
individualscc eastasiaa othercountryy physicalhealthh mentalhealthh ///
numberofscvariabless agee incomee olss orhrr tcalculatedbypvaluee ///
if esample == 1, noc vce(cluster id)

*--------------------------------------------------------*
*   TABLE: RandomEffects(Weight2) // Stepwise Regression  *
*--------------------------------------------------------*

////////////////////////////////////////////
//////////////  FULL SAMPLE  ///////////////
////////////////////////////////////////////
drop esample 
quietly regress retstatR conss repubbiasR bondingg bridgingg pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight]
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if esample == 1, backward ///
bic fix(conss bondingg bridgingg physicalhealthh mentalhealthh)

// Random Effects - Equal weight to each study (Column 4)
regress retstatR conss bondingg bridgingg physicalhealthh mentalhealthh ///
repubbiasR panell ivv eastasiaa othercountryy numberofscvariabless agee genderr ///
incomee olss seotherr tcalculatedbypvaluee [pweight = weight]  if esample == 1, ///
noc vce(cluster id)
test (bondingg bridgingg)

////////////////////////////////////////////////
//////////////  PHYSICAL HEALTH  ///////////////
////////////////////////////////////////////////
drop esample 
quietly regress retstatR conss repubbiasR bondingg pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if physicalhealth == 1
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight]  ///
if esample == 1, backward bic fix(conss bondingg)

// Random Effects - Equal weight to each study (Column 4)
regress retstatR conss bondingg repubbiasR individualscc panell eastasiaa ///
westnortheuropee highincomee othercountryy genderr maritalstatuss hlmm ///
seotherr tcalculatedbypvaluee [pweight = weight] if esample == 1, noc vce(cluster id)

//////////////////////////////////////////////
//////////////  MENTAL HEALTH  ///////////////
//////////////////////////////////////////////
drop esample 
quietly regress retstatR conss repubbiasR bondingg pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if mentalhealth == 1
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight] if esample == 1, ///
backward bic fix(conss bondingg)

// Random Effects - Equal weight to each study (Column 4)
regress retstatR conss bondingg repubbiasR pubyearr individualscc eastasiaa westnortheuropee ///
numberofscvariabless maritalstatuss olss tnormall  ///
tcalculatedbypvaluee [pweight = weight] if esample == 1, noc vce(cluster id)

//////////////////////////////////////////////
//////////////  GENERAL HEALTH  //////////////
//////////////////////////////////////////////
drop esample 
quietly regress retstatR conss repubbiasR bondingg pubyearr individualscc panell ivv ///
eastasiaa westnortheuropee highincomee othercountryy ///
selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight] if generalhealth == 1
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee olss ///
orhrr hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight] if esample == 1, ///
backward bic fix(conss bondingg)

// Random Effects - Equal weight to each study (Column 4)
regress retstatR conss bondingg repubbiasR pubyearr  ///
eastasiaa westnortheuropee othercountryy selfreportedd numberofscvariabless  ///
agee genderr educationn maritalstatuss incomee olss hlmm seotherr [pweight = weight] ///
if esample == 1, noc vce(cluster id)

/////////////////////////////////////////////////////////////////
//////////////  FULL SAMPLE w/ INTERACTION TERMS  ///////////////
/////////////////////////////////////////////////////////////////
drop esample
quietly regress retstatR conss repubbiasR bondingg bondphysicall bondmentall pubyearr ///
individualscc panell ivv eastasiaa westnortheuropee highincomee othercountryy ///
physicalhealthh mentalhealthh selfreportedd numberofscvariabless agee genderr ///
educationn maritalstatuss incomee olss orhrr hlmm seotherr tnormall ///
tcalculatedbypvaluee [pweight = weight]
gen esample = e(sample)

vselect retstatR repubbiasR pubyearr individualscc panell ivv eastasiaa westnortheuropee ///
highincomee othercountryy selfreportedd ///
numberofscvariabless agee genderr educationn maritalstatuss incomee ///
olss orhrr hlmm seotherr tnormall tcalculatedbypvaluee [pweight = weight] ///
if esample == 1, backward bic fix(conss bondingg bondphysicall bondmentall ///
physicalhealthh mentalhealthh)

// Random Effects - Equal weight to each study (Column 4)
regress retstatR conss bondingg bondphysicall bondmentall ///
physicalhealthh mentalhealthh repubbiasR individualscc panell ivv  ///
eastasiaa othercountryy numberofscvariabless  ///
agee genderr incomee olss seotherr tcalculatedbypvaluee ///
[pweight = weight] if esample == 1, noc vce(cluster id)

log close

 